import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';

export type UserDocument = User & Document;

@Schema({
  timestamps: {
    createdAt: 'createdAt',
    updatedAt: 'updatedAt',
  },
})
export class User extends Document {
  // 用户名称
  @Prop({ required: true, type: String })
  userName: string;

  // 用户密码
  @Prop({ required: true, type: String })
  passWord: string;

  // 用户真实姓名
  @Prop({ required: true, type: String })
  realName: string;

  // 部门id
  @Prop({ type: Types.ObjectId, ref: 'Department', required: true })
  depatID: Types.ObjectId;

  // 是否是超级管理员
  @Prop({ default: false })
  isSuperAdmin: boolean;

  // 是否删除
  @Prop({ default: false })
  isDelete: boolean;
}

export const UserSchema = SchemaFactory.createForClass(User);
